<?php

namespace app\api\controller;

use think\Controller;
use think\Request;
use app\api\model\Booklist as BookModel;

class Booklist extends Controller
{
    protected $bookmodel;

    public function __construct()
    {
        $this->bookmodel = new BookModel();
    }

    public function index()
    {
        return $this->book();
    }

    public function book(Request $request = null)
    {
        // $a = $request->param('a');
        $c = $request->param('c');
        if ($c != 'data') {
            return ['status'=>1];
        }
        if ($result = $this->bookmodel->limit(10)->select()) {
            $data = array();
            foreach ($result as $v) {
                $data[] = $v->toArray();
            }
            // var_dump($data);
            return json(['status'=>0,'data'=>$data]);
        }
    }
}
